package com.gitee.wsl.data.state

/**
 * Marker interface to indicate a [KalugaState] should execute an action before creating a new state to transition to.
 */
interface HandleBeforeCreating {
    /**
     * Called while transitioning to a new state before the new state is created
     */
    suspend fun beforeCreatingNewState()
}

/**
 * Marker interface to indicate a [KalugaState] should execute an action after creating a new state to transition to.
 * @param NewState the type of [KalugaState] created
 */
interface HandleAfterCreating<NewState : KalugaState> {
    /**
     * Called while transitioning to a new state after the new state is created
     *
     * @param newState the newly created state
     */
    suspend fun afterCreatingNewState(newState: NewState)
}

/**
 * Marker interface to indicate a [KalugaState] should execute an action after it has been transitioned into a new state.
 * @param NewState the type of [KalugaState] transitioned to.
 */
interface HandleAfterNewStateIsSet<NewState : KalugaState> {

    /**
     * Called while transitioning to a new state after the new state is set.
     *
     * @param newState the newly set [KalugaState]
     */
    suspend fun afterNewStateIsSet(newState: NewState)
}

/**
 * Marker interface to indicate a [KalugaState] should execute an action before replacing another state.
 * @param OldState the type of [KalugaState] that is to be replaced.
 */
interface HandleBeforeOldStateIsRemoved<OldState : KalugaState> {

    /**
     * Called while transitioning from an old state before it is removed.
     *
     * @param oldState the [KalugaState] to be removed
     */
    suspend fun beforeOldStateIsRemoved(oldState: OldState)
}

/**
 * Marker interface to indicate a [KalugaState] should execute an action after replacing another state.
 * @param OldState the type of [KalugaState] that was replaced.
 */
interface HandleAfterOldStateIsRemoved<OldState : KalugaState> {

    /**
     * Called while transitioning from an old state after it is removed
     *
     * @param oldState the removed state
     */
    suspend fun afterOldStateIsRemoved(oldState: OldState)
}